package com.fasteat.mall.service.client;

import com.fasteat.common.entity.Result;
import com.fasteat.mall.entity.SearchCondition;
import com.fasteat.mall.handler.ProductSearchClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


/**
 * @author ghost
 * @descprition 商品搜索远程调用
 * @since 2021-2-8
 */
@FeignClient(value = "fasteat-search-service", fallback = ProductSearchClientFallback.class)
public interface ProductSearchClient {

	/**
	 * 分页高亮默认方式搜索商品
	 *
	 * @param condition
	 * @return
	 */
	@PostMapping("/search/mall")
	public Result searchProductWithHighlightAndPage(@RequestBody SearchCondition condition);


	/**
	 * 分页高亮带排序搜索商品
	 *
	 * @param condition
	 * @param salesVolumeSort
	 * @param priceSort
	 * @param timeSort
	 */
	@PostMapping("/search/mall/{salesVolumeSort}/{priceSort}/{timeSort}")
	public Result searchProductWithHighlightAndPageAndSort(@RequestBody SearchCondition condition,
														   @PathVariable(name = "salesVolumeSort") int salesVolumeSort,
														   @PathVariable(name = "priceSort") int priceSort,
														   @PathVariable(name = "timeSort") int timeSort);

	/**
	 * 通过商品id删除商品
	 *
	 * @param id
	 * @return
	 */
	@DeleteMapping("/search/mall/{id}")
	public Result deleteProductById(@PathVariable(name = "id") String id);
}
